<?php

//$variable = "";

//$variable .= generaColumnTextField( "Codi", "codi", 100, 3, 1, 0);
//$variable .= generaColumnNumberField( "Periode", "periode", 60, 2, 0, 0, 1, 0);
//$variable .= generaColumnNumberFieldNoEdit( "id2", "id2", 60, 1, 0);
//$variable .= generaColumnDateField( "Data inici", "data_inici", 100, 'd/m/Y', 1, 0);
//$variable .= generaColumnTimeField( "Hora", "hora", 100, "H:i", 30, 1, 0 );
//$variable .= generaColumnComboBox( "Agenda", "id_agenda", 100, "id_agenda", "codi_agenda", "id_agenda.php", 1, 0 );

//echo $variable;

/* IMG FIELD */
function generaColumnImgField( $header, $dataIndex, $width, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			renderer: function(value, cell){ 
				var str = '';
				str = \"<img src='\"+ value +\"' style='max-height:35px; max-width:90px;' title='\"+ value +\"' />\";
				return str;
			},
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* TEXT FIELD */
function generaColumnTextField( $header, $dataIndex, $width, $maxLength, $allowBlank, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			editor: new Ext.form.TextField({
				maxLength: $maxLength,
				allowBlank: $allowBlank
			}),
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* TEXT FIELD NO EDIT */
function generaColumnTextFieldNoEdit( $header, $dataIndex, $width, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* NUMBER FIELD */
function generaColumnNumberField( $header, $dataIndex, $width, $maxLength, $allowDecimals, $allowNegative, $allowBlank, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			editor: new Ext.form.NumberField({
				maxLength: $maxLength,
				allowDecimals: $allowDecimals,
				allowNegative: $allowNegative,
				allowBlank: $allowBlank
			}),
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* NUMBER FIELD NO EDIT */
function generaColumnNumberFieldNoEdit( $header, $dataIndex, $width, $renderer, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
	";
			if( $renderer ){
				$variable .= "
			renderer: function(value, cell){ 
				cell.css = 'readonlycell';
				return value;
	        },
	";
			}
	$variable .= "
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* DATE FIELD */
function generaColumnDateField( $header, $dataIndex, $width, $format, $allowBlank, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			renderer: Ext.util.Format.dateRenderer('$format'),
			editor : new Ext.form.DateField({
				format : '$format',
				allowBlank: $allowBlank
			}),
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* HTML EDITOR */


/* TEXT AREA */


/* FILE UPLOAD FIELD */


/* TIME FIELD */
function generaColumnTimeField( $header, $dataIndex, $width, $format, $increment, $allowBlank, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			editor: new Ext.form.TimeField({
				format: '$format',
				//minValue: '8:00',
				//maxValue: '22:00',
				increment: $increment,
				allowBlank: $allowBlank
			}),
			hidden: $hidden,
			sortable: true,
			menuDisabled: true
	";
	
	return $variable;
}

/* COMBO BOX */
function generaColumnComboBox( $header, $dataIndex, $width, $valueField, $displayField, $storeURL, $allowBlank, $hidden ){
	$variable = '';
	
	$variable = "
			header: '$header',
			dataIndex: '$dataIndex',
			width: $width,
			editor: new Ext.form.ComboBox({
				mode:'remote',
				forceSelection: true,
				triggerAction:'all',
				editable: false,
				//valueField:'$valueField',
				displayField:'$displayField',
				allowBlank: $allowBlank,		
				store: new Ext.data.JsonStore({
					autoLoad: true,
					url: '$storeURL',
					root: 'results',
					fields:['$valueField', '$displayField']
				})			
			 }),
			hidden: $hidden,
			sortable: true,
			menuDisabled: true	
	";
	return $variable;
}

?>